#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>

class MakeManager
{
public:
    MakeManager(std::string gen_path);

    // write include
    void init() ;

    // todo
    // add download to the direct-folder

    /// @brief make a file
    /// @details generate a method: void write_file_name(){}
    /// @param file_name
    /// @param file_extension be like .txt .proto
    /// @param data
    void write_method(std::string const &file_name, std::string const &file_extension, std::vector<std::string> const &data);

    void write_main();

    void write_CMakeLists_txt();

    ~MakeManager();

private:
    bool is_writer_ok() const;

    template <typename... Args>
    void write(Args &&...args) 
    {
        if (!is_writer_ok())
            return;
        std::stringstream oss;
        (writer_ << ... << args);

        writer_ << std::endl;
    }

private:
    struct Para
    {
        std::string name;
        std::string ext;
    };
    
    std::string gen_path_;
    std::vector<Para> method_list_;
    std::vector<Para> method_list_invalid_name_;
    std::fstream writer_;
};
